<?php

namespace App\Http\Controllers;

use Gregwar\Captcha\CaptchaBuilder;
use Illuminate\Http\Request;

class CapcodeController extends Controller
{
    public function captcha(Request $request){
        $builder = new CaptchaBuilder();
        $builder->build(150,50);

        //获取验证码的内容,并转化为小写
        $phrase = strtolower($builder->getPhrase());

        $request->session()->flash('captchaSession',$phrase);
        ob_clean();

        return response($builder->output())->header('Content-type','image/jpeg');
    }
}
